x11/surface: Compute size after update too
authorJonas Ådahl <jadahl@gmail.com>
Sat, 5 Dec 2020 10:13:07 +0000 (11:13 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Mon, 7 Dec 2020 19:37:29 +0000 (20:37 +0100)
This will sometimes mean a frame is skipped if a resize was requested
during the update phase of the frame dispatch. Not doing so can cause
trying to allocate a window smaller than the minimum size of the widget.

gdk/x11/gdksurface-x11.c

index 0348e9b85bf4af389449fcd4541c51b2c11268e4..8c65183f5d2b5a4df9f0943b5d3de4d2b95b5fc4 100644 (file)
@@ -1002,6 +1002,19 @@ on_frame_clock_before_paint (GdkFrameClock *clock,
   gdk_x11_surface_begin_frame (surface, FALSE);
 }
 
+static void
+on_frame_clock_after_update (GdkFrameClock *clock,
+                             GdkSurface    *surface)
+{
+  GdkX11Surface *impl = GDK_X11_SURFACE (surface);
+
+  if (impl->compute_size_source_id)
+    {
+      g_clear_handle_id (&impl->compute_size_source_id, g_source_remove);
+      compute_size_idle (surface);
+    }
+}
+
 static void
 on_frame_clock_after_paint (GdkFrameClock *clock,
                             GdkSurface     *surface)
@@ -1024,6 +1037,8 @@ connect_frame_clock (GdkSurface *surface)
 
       g_signal_connect (frame_clock, "before-paint",
                         G_CALLBACK (on_frame_clock_before_paint), surface);
+      g_signal_connect_after (frame_clock, "update",
+                              G_CALLBACK (on_frame_clock_after_update), surface);
       g_signal_connect (frame_clock, "after-paint",
                         G_CALLBACK (on_frame_clock_after_paint), surface);
 
@@ -1043,6 +1058,8 @@ disconnect_frame_clock (GdkSurface *surface)
 
       g_signal_handlers_disconnect_by_func (frame_clock,
                                             on_frame_clock_before_paint, surface);
+      g_signal_handlers_disconnect_by_func (frame_clock,
+                                            on_frame_clock_after_update, surface);
       g_signal_handlers_disconnect_by_func (frame_clock,
                                             on_frame_clock_after_paint, surface);